#include "cpu/exec/helper.h"
#include "cpu/decode/modrm.h"

make_helper(nop) {
	print_asm("nop");
	return 1;
}

make_helper(int3) {
	void do_int3();
	do_int3();
	print_asm("int3");

	return 1;
}

make_helper(lea) {
	ModR_M m;
	m.val = instr_fetch(eip + 1, 1);
	int len = load_addr(eip + 1, &m, op_src);
	// reg_l(m.reg) = op_src->addr;
	//把上面那行重新实现一遍
	// Log("m.reg = %d", m.reg);
	switch (m.reg) {
		case 0:
			cpu.eax = op_src->addr;
			break;
		case 1:
			cpu.ecx = op_src->addr;
			break;
		case 2:
			cpu.edx = op_src->addr;
			break;
		case 3:
			cpu.ebx = op_src->addr;
			break;
		case 4:
			cpu.esp = op_src->addr;
			break;
		case 5:
			cpu.ebp = op_src->addr;
			break;
		case 6:
			cpu.esi = op_src->addr;
			break;
		case 7:
			cpu.edi = op_src->addr;
			break;
		default:

			assert(0);
	}

	print_asm("leal %s,%%%s", op_src->str, regsl[m.reg]);
	return 1 + len;
}
